#!/bin/sh


export LC_ALL=en_US.UTF-8
if [ $# -lt 3 ];then
   echo "$0 cmd logdir logname"
   exit 1
fi

cmd=$1
logdir=$2
logname=$3

mkdir -p ${logdir}
reallogfile=${logdir}/${logname}.`date '+%Y%m%d'`

while [ 1 ]
do
	date "+%a %b %d %H:%M:%S CST %Y" >>${reallogfile}
	$cmd >>${reallogfile}
	sleep 3
done